import http from "../utils/request"
import {PageRequestType, ResponseType, PageResponseType} from "../types/Response";
import {AxiosResponse} from "axios";

const apiPrefix:string = "/enterprise";

export interface EnterpriseType {
    // 用户ID
    id?:string|null|undefined
    // 姓名
    name?:string|null|undefined
    // 岗位
    job?:string|null|undefined
    // 身份证号码
    id_card?:string|null|undefined
    // 出生日期
    birthday?:any|null|undefined
    // 性别(1男2女)
    gender?:number|null|undefined
    // 地址
    place?:string|null|undefined
    // 民族
    nation?:string|null|undefined
    // 证件照
    identification_photo?:string|null|undefined
    // 受教育程度
    degree_of_education?:string|null|undefined
    // 联系电话
    phone?:string|null|undefined
    // 身体健康状况
    health_condition?:string|null|undefined
    // 用户状态(0审核中,1已通过,-1未通过)
    status?:number|null|undefined
}

export interface EnterprisePageSearchType extends PageRequestType, EnterpriseType {

}


export async function addEnterprise(data: EnterpriseType): Promise<AxiosResponse<ResponseType<null>>> {
    return await http.request({
        data: data,
        url: apiPrefix,
        method: 'post'
    })
}

export async function deleteEnterpriseById(id: string): Promise<AxiosResponse<ResponseType<null>>> {
    return await http.request({
        params: {
            id
        },
        url: apiPrefix+'/id',
        method: 'delete'
    })
}

export async function deleteEnterpriseByIds(ids: string[]): Promise<AxiosResponse<ResponseType<null>>> {
    return await http.request({
        params: {
            ids
        },
        url: apiPrefix+'/batch',
        method: 'delete'
    })
}


export async function searchEnterpriseById(id: string): Promise<AxiosResponse<ResponseType<EnterpriseType>>> {
    return await http.request({
        params: {
            id
        },
        url: apiPrefix+'/id',
        method: 'get'
    })
}

export async function searchEnterprise(params: EnterpriseType): Promise<AxiosResponse<ResponseType<EnterpriseType[]>>> {
    return await http.request({
        params: params,
        url: apiPrefix,
        method: 'get'
    })
}

export async function searchEnterpriseByPage(params: EnterprisePageSearchType): Promise<AxiosResponse<ResponseType<PageResponseType<EnterpriseType>>>> {
    return await http.request({
        params: params,
        url: apiPrefix+'/page',
        method: 'get'
    })
}


export async function updateEnterpriseById(data: EnterpriseType): Promise<AxiosResponse<ResponseType<null>>> {
    return await http.request({
        data: data,
        url: apiPrefix,
        method: 'put'
    })
}
